package es.deusto.ingenieria.sd.tralala.server.db;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import es.deusto.ingenieria.sd.tralala.server.data.Cancion;
import es.deusto.ingenieria.sd.tralala.server.data.Usuario;
import es.deusto.ingenieria.sd.tralala.server.data.usuarioAssembler;
import es.deusto.ingenieria.sd.tralala.server.data.usuarioDTO;

public class CargarDatos {
	
	public static void main (String [] args){
		 Usuario u1 = new Usuario("Ramon", "ramon@gmail.com");
		 Usuario u2 = new Usuario("Juan","Juan@gmail.com");
		 byte[] array= new byte[2];
		 Cancion c1= new Cancion("Sharp Dressed Man", "ZZtop", "Eliminator","Rock", 6.0, "Laralalala", 2.0, array);
		 Cancion c2= new Cancion("Clint Eastwood", "Gorillaz", "Gorillaz","Electronic-Hip Hop/Rap", 6.0, "Laralalala", 2.0, array);
		 
		 
		 JDO.getInstance().insertarObjeto(u1);
		 JDO.getInstance().insertarUsuario(u2);
		 JDO.getInstance().insertarCancion(c1);
		 
		usuarioDTO DTO = usuarioAssembler.getInstance().createDTO(JDO.getInstance().recuperarUsuario("Ramon"));
		 
		 System.out.println("DTo nombre " +DTO.getNombre());
		
		
		
	}

	public static byte[] inputStreamToByteArray(String Direccion) throws IOException {
		InputStream      inStream = new FileInputStream("song.mp3");
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
	    byte[] buffer = new byte[8192];
	    int bytesRead;
	    while ((bytesRead = inStream.read(buffer)) > 0) {
	        baos.write(buffer, 0, bytesRead);
	    }
	    return baos.toByteArray();
	}
}
